package com.basker.pisces.core;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public interface ISupportSort {

    static final Comparator<ISupportSort> SORT_COMPARATOR = (e1, e2) -> {
        Integer sort1 = e1.getSort();
        Integer sort2 = e2.getSort();

        sort1 = sort1 != null ? sort1 : 0;
        sort2 = sort2 != null ? sort2 : 0;

        return sort1.compareTo(sort2);
    };

    static void sort(List<ISupportSort> elements) {
        Collections.sort(elements, SORT_COMPARATOR);
    }

    Integer getSort();

    void setSort(Integer sort);
}
